QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Meshes

Figure 12 shows a mesh.

Figure 12 A mesh

Labels

ASCII
Mesh
Binary
mesh ( = 0x6D657368 )

Mesh face Data Type

Int                 nFaceVertexIndices
Uns                 faceVertexIndices[|nFaceVertexIndices|]
nFaceVertexIndices
An integer, the absolute value of which is equal to the number of indices to the vertices of a mesh face or mesh contour: that is, equal to the number of vertices of that face or contour. The value of this field may be positive or negative. A positive value indicates that this mesh face object specifies a face (to which attributes may be assigned). A negative value indicates that this mesh face object specifies a hole (here called a contour ). The absolute value of the value in this field must be at least 3.
faceVertexIndices [ ]
An array of indices to elements of the array vertices[] , where i is the index of vertices[i] . This array specifies a verticed object by giving the indices of its vertices. The specified object is either a face or a contour of the mesh, as determined by the value of nVertices . The number of fields of this array must equal the absolute value of the value of the nVertices field.

Description

The mesh face data type is used to specify a vertexed object and to specify whether that object is a face or a contour of a mesh. This data type occurs only as the value of a field in the faces[] array of a mesh specification.

Data Format

Uns32                               nVertices
Vertex3D                            vertices[nVertices]
Uns32                               nFaces
Uns32                               nContours
MeshFace                            faces[nFaces + nContours]
nVertices
The number of vertices of the mesh. The value of this field must be at least 3.
vertices[]
An array of vertices.
nFaces
The number of faces of the mesh.
nContours
The number of contours of the mesh (that is, the number of holes in the mesh).
faces[]
An array of mesh face objects, each of which specifies either a face or a contour (hole) of the mesh. The size of this array is equal to the sum of the values of the nVertices and nContours fields. Each array element that specifies a face should precede all array elements that specify holes in that face; any such latter elements may occur in any order but should be grouped together and should precede any subsequent array element that specifies a face: if the value of field i specifies a face intended to have n holes, then the objects that specify those holes must occupy the next n fields: that is, fields i +1, ..., i + n .

Data Size

sizeof(MeshFace) = fabs(Int) * 4

sizeof(Mesh) = 4 + nVertices * 12 + 8 + sizeof(faces[0...nFaces+nContours-1])

Description

A mesh is an object defined by a collection of vertices, faces, and contours. Meshes may be used to model polyhedra, grids, and other faceted objects. A mesh may have a boundary. The term contour is used here to refer to a polygonal hole contained in a single face of a mesh. A mesh face (or contour) is a list of vertices that defines a polygonal facet. A face (or contour) need not be planar, and a contour and its surrounding face need not be coplanar; however, rendering of a mesh having a nonplanar face or contour, or having a contour not coplanar with its surrounding face, may lead to unexpected results.

The specification of a mesh includes an array of vertices and an array of faces and contours. The vertices of a mesh are indexed by array position; these indices are used to specify the faces and contours of that mesh. Faces and contours are also indexed by array position; this index does not distinguish between faces and contours. Both of these indices are used in the specification of child objects.

Attributes may be attached separately and selectively to the vertices, faces, face edges, and corners of a mesh.

Default Surface Parameterization

None.

Parent Hierarchy

Shared, shape, geometry.

Parent Objects

None.

Child Objects

Face attribute set list (optional), vertex attribute set list (optional), mesh corners (optional), mesh edges (optional). See "Mesh Corners" , and "Mesh Edges" , for descriptions of these objects.

Example

Mesh (
    10                                      # nVertices
        -1 1 1                              # enumeration of vertices
        -1 1 -1
        1 1 -1
        1 -1 -1
        1 -1 1
        0 -1 1
        -1 -1 0
        -1 -1 -1
        1 1 1
        -1 0 1
    7                                       # nFaces
    0                                       # nContours
        3 6 5 9                             # enumeration of contours
        5 7 6 9 0 1
        4 2 3 7 1
        4 2 8 4 3
        4 1 0 8 2
        5 4 8 0 9 5
        5 3 4 5 6 7
)

Default Size

None.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |